constant
Constants are symbols used as descriptive replacements for literal values. They
represent fixed numeric or string values that do not change as programs run. Attempts to
redefine constants cause compile time errors. The data type of constants is
determined by the data type of the literal or constant assigned to it. Type suffixes
are not valid on constants, except for $ on string constants. Only literals,
constants, and bitfield specs can be assigned to constants.
local constant
Local constants are distinguished by $ prefixes, as in $SIZE and $SHAPE. They
are declared, defined, and typed within functions when values are assigned to them.
Local constants are visible only within the function that defines them.
shared constant
Shared constants have $$ prefixes, as in $$YES and $$NO. They are declared, defined,
and typed when values are assigned to them. Shared constants must be defined in the
prolog after all function and shared data declarations. Shared constants that are
"exported" by a library become defined in a program when it "imports"
the library.
system constants
System constants are shared constants predefined for all programs. The only ones
currently defined are $$FALSE and $$TRUE.
variable
Variables are symbols representing values, or groups of values, that can change as a
program executes. Simple variables, often just called variables, are single numeric
values in one of several data types. String variables, or strings, are elastic
series of unsigned bytes. Array variables, or arrays are one or more dimensional
arrays of any type of data. Composite variables, or composites are fixed-size
collections of simple variables, fixed-size arrays, fixed-length strings, and other
composites.
Variables, strings, arrays, and composites are all are called variables. When distinction between the various kinds are important, the individual names are used.
simple variable
Simple variables are analogous to algebraic variables and represent single numeric values.
Simple variables range from 1 byte (SBYTE , UBYTE) to 8 bytes (GIANT , DOUBLE).
Signed integers, unsigned integers, and floating point numbers are simple data types. The built-in simple data types include:
SBYTE 8-bit signed
integer
UBYTE 8-bit unsigned integer
SSHORT 16-bit signed integer
USHORT 16-bit unsigned integer
SLONG 32-bit signed integer
ULONG 32-bit unsigned integer
XLONG 32/64 bit generic integer
GOADDR 32/64 bit address integer
SUBADDR 32/64 bit address integer
FUNCADDR 32/64 bit address integer
GIANT 64-bit signed integer
SINGLE 32-bit floating point
DOUBLE 64-bit floating point
bit field
Bit fields are arbitrary length fields of bits in integer variables. Bit field operations
work with 1 - 32 bit wide fields starting at any bit position from 0 (LSb) to 31 (MSb).
bitfield intrinsics
CLR() clear arbitrary bit field to zeros
SET() set arbitrary bit field to ones
MAKE() make an arbitrarily bit field
EXTS() extract arbitrary bit field signed
EXTU() extract arbitrary bit field unsigned
brace notation for bitfields
Brace notation can be used to extract signed and unsigned bit fields, as in
aa=token{{3,24}} (signed) and aa = token{3,24} (unsigned).
In aa = token{3,24} , the three bit field starting at bit 24 is extracted from token and assigned to aa . The upper 29 bits of aa become zero since single braces specify unsigned bitfields. Double braces specify signed bitfields, so aa = token{{3,24}} fills the upper bits of aa with the most significant bit of the extracted 3-bits.
BITFIELD()
The BITFIELD() intrinsic creates descriptive bitfield constants and variables in a
portable, machine independent, way.
The following examples show four variables and constants being given values by the BITFIELD() intrinsic, then extracted as signed and unsigned bitfields from variable token.
$$TYPE = BITFIELD (5, 16) ' 5 bits 16-20
$SCOPE = BITFIELD (3, 21) ' 3 bits 21-23
white = BITFIELD (3, 29) ' 3 bits 29-31
kind = BITFIELD (5, 24) ' 5 bits 24-28
...
tokenType = token{$$TYPE} ' 5 bits 16-20
tokenScope = token{$SCOPE} ' 3 bits 21-23
tokenWhite = token{{white}} ' 3 bits 29-31
tokenKind = token{kind} ' 5 bits 24-28